package com.sky.mapper;

import com.sky.anno.AutoFill;
import com.sky.constant.AutoFillConstant;
import com.sky.entity.User;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;

@Mapper
public interface UserMapper {
    /**
     * 根据openid查询用户
     * @param openid
     * @return
     */
    @Select("select * from user where openid = #{openid}")
    User getByOpenid(String openid);

    //@AutoFill(value = OperationType.INSERT)
    void insert(User user);

    @Select("select * from user where id = #{userId}")
    User getById(Long userId);

    @Select("select count( *) from user where date (create_time) < #{localDate};")
    Integer getUserStatistics(LocalDate localDate);

    @Select("select count( *) from user where date (create_time) = #{localDate};")
    Integer getNewUserStatistics(LocalDate localDate);
}
